package com.xx.servlet.model;

import com.xx.bean.Cart;
import com.xx.bean.User;
import com.xx.service.OrderService;
import com.xx.service.impl.OrderServiceImpl;
import com.xx.servlet.base.ModelBaseServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class OrderClientServlet extends ModelBaseServlet {
    private OrderService orderService = new OrderServiceImpl();

    //结算
    public void checkout(HttpServletRequest req, HttpServletResponse res) throws IOException {
        HttpSession session = req.getSession();
        Cart cart = (Cart) session.getAttribute("cart");
        User loginUser = (User) session.getAttribute("loginUser");
        String orderSequence = orderService.checkout(loginUser, cart);
        session.removeAttribute("cart");
        req.setAttribute("orderSequence",orderSequence);
        processTemplate("cart/checkout",req,res);
    }
}
